package com.example.demo.mapper;/**
 * ClassName: RepairMapper
 * Package: com.example.demo.mapper
 * Description:
 *
 * @Author 理理
 * @Create 2024/11/16 19:14
 * @Version 1.0
 */

import com.example.demo.entity.Repair;
import com.example.demo.entity.Subscribe;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 *
 *@title: RepairMapper
 *@Author: Tangerine
 *@Date: 2024/11/16 19:14
 *@version 1.0
 */
@Mapper
public interface RepairMapper {
    //查询所有数据
    @Select("select * from repair")
    List<Repair> findAll();

    //分页查询数据,多个参数需要增加注解标识指定参数
    @Select("select * from repair limit #{pageNum},#{pageSize}")
    List<Repair> selectPage(@Param("pageNum") Integer pageNum, @Param("pageSize") Integer pageSize);

    //查询记录总数
    @Select("select count(*) from repair")
    Integer selectTotal();

    //插入数据
    @Insert("insert into repair(type,number,cause,state,result) " +
            "VALUES(#{type},#{number},#{cause},#{state},#{result});")
        //这里只是做测试使用
    int insert(Repair repair);

    //更新数据
    @Update("update repair set type=#{type},number=#{number}," +
            "cause=#{cause},state=#{state},result=#{result} where id=#{id}")
    int update(Repair repair);

    //删除数据
    @Delete("delete from repair where id=#{id}")
    int deleteById(@Param("id") Integer id);

    //历史维修全部
    @Select("select * from repair where studentNumber=#{studentNumber}")
    List<Repair> findHistory(@Param("studentNumber") String studentNumber);

    //历史维修分页
    @Select("select * from repair where studentNumber=#{studentNumber} limit #{pageNum},#{pageSize}")
    List<Repair> findHistoryPage(@Param("studentNumber") String studentNumber,@Param("pageNum") Integer pageNum,@Param("pageSize") Integer pageSize);

}
